package com.bocaizp.operation.mapper;

import com.bocaizp.pojo.DTO.AnalysisHotDTO;
import com.bocaizp.pojo.DTO.AnalysisJobNumberDTO;
import com.bocaizp.pojo.DTO.SalaryDTO;
import com.bocaizp.pojo.VO.AdminDataHierarchyMINVO;
import com.bocaizp.pojo.VO.AnalysisNameValueVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Author : huang jie
 * Date : 2024/5/6 16:53
 **/
@Mapper
public interface UpdateDataMapper {

	/**
	 * 获取所有行业
	 * @return
	 */
	@Select("select father from position group by father")
	List<String> getindsutry();

	/**
	 * 获取行业旧数据
	 *
	 * @param in
	 * @return
	 */
	@Select("select date_a, date_b, date_c, date_d, date_e, date_f, date_g from industry_hot_salary where industry = #{in} and status = #{status}")
	AnalysisHotDTO getOldHot(@Param("in") String in,@Param("status") int status);

	/**
	 * 获取行业热度数据
	 * @param in
	 * @return
	 */
	@Select("select sum(hot) from job_data where industry = #{in}")
	int getNewHot(String in);

	/**
	 * 更新行业热度数据
	 * @param analysisHotDTO
	 */
	void updateHot(AnalysisHotDTO analysisHotDTO);

//	@Select("select ")
//	LinkedList<Integer> getOldSalary(String in);

	/**
	 * 获取行业薪资数据
	 * @param in
	 * @return
	 */
	@Select("select salary_bottom,salary_top,salary_month from job_data where industry = #{in}")
	List<SalaryDTO> getSalary(String in);

	/**
	 * 获取全国岗位分布新数据
	 * @return
	 */
	@Select("select province as name, count(*) as value from job_data group by province")
	List<AnalysisNameValueVO> getCountryJob();

	/**
	 * 更新全国岗位分布数据
	 * @param name
	 * @param value
	 */
	@Update("update analysis_country_job set value = #{value} where name = #{name}")
	void updateCountryJob(@Param("name") String name,@Param("value") int value);

	/**
	 * 获取学历占比新数据
	 * @return
	 */
	@Select("select degrees as name, count(*) as value from job_data group by degrees")
	List<AnalysisNameValueVO> getDegrees();

	/**
	 * 更新学历占比数据
	 * @param name
	 * @param value
	 */
	@Update("update analysis_degrees set value = #{value} where name = #{name}")
	void updateDegrees(@Param("name") String name,@Param("value") int value);

	/**
	 * 获取行业的热敷平均值
	 * @param in
	 * @return
	 */
	@Select("select avg(hot) from job_data where industry = #{in}")
	int getAvgHot(String in);

	/**
	 * 获取岗位总数旧数据
	 *
	 * @param id
	 * @return
	 */
	@Select("select data_a, data_b, data_c, data_d, data_e, data_f, data_g, data_h, data_i from analysis_job_number where id = #{id}")
	AnalysisJobNumberDTO getOldNumber(int id);

	/**
	 * 获取岗位总数新数据
	 * @return
	 */
	@Select("select count(*) from job_data")
	int getNewNumber();

	/**
	 * 更新岗位总数
	 * @param number
	 */
	@Update("update analysis_job_number set data_a = #{dataA},data_b = #{dataB},data_c = #{dataC},data_d = #{dataD},data_e = #{dataE}," +
			"data_f = #{dataF},data_g = #{dataG},data_h = #{dataH},data_i = #{dataI} where id = #{id}")
	void inserNumber(AnalysisJobNumberDTO number);

	@Select("select id from user_forecast order by update_time limit 0,1")
	Long selectUser();

	@Update("update user_forecast set value_a = #{dataOne},value_b = #{dataTwo},value_c = #{dataThree}," +
			"value_d = #{dataFour},value_e = #{dataFive},value_f = #{dataSix},value_g = #{dataSeven},value_h = #{dataEight} where id = #{id}")
	void userStep(AdminDataHierarchyMINVO adminDataHierarchyMINVO);
}
